package network.tpa1;

import java.net.DatagramPacket;
import java.net.InetAddress;

import network.AbstractUserSignal;

import signals.Signal;

/**
 * Classe correspond à un signal utilisateur du groupe TPA1.
 *
 */
public class UserSignalA1 extends AbstractUserSignal {
	
	private Signal signal = null ;

	/**
	 * Create a new UserSignal corresponding to the packet. The UserSignal
	 * contain information about the signal and the host that sent it.
	 * 
	 * @param packet
	 */
	public UserSignalA1 (DatagramPacket packet) {
		super (packet) ;
		this.signal = Signal.deserialize(packet.getData(), packet.getLength()) ;
	}
	
	/**
	 * Create a new UserSignal corresponding to specified signal and receiver address.
	 * 
	 * @param signal
	 * @param receiver
	 */
	public UserSignalA1 (Signal signal, InetAddress receiver) {
		super (receiver) ;
		this.signal = signal ;
	}
	
	/**
	 * @return the signal
	 */
	public Signal getSignal () {
		return this.signal ;
	}

	@Override
	public byte[] serialize() {
		return this.signal.serialize();
	}	

}
